import * as PIXI from './core/pixi.min'
import pixiHock from './plugin/pixi.hock'
import './core/weapp-adapter'
import './core/symbol'

class One extends PIXI.Application {
  constructor (config = {}) {
    super(One.INIT_ONE(config))
    this._initOne()
  }
  _initOne () {
    this._initDefaultPulgin()
  }
  // 加载默认插件
  _initDefaultPulgin () {
    let {DEFAULT_PLUGIN} = this.constructor
    DEFAULT_PLUGIN.forEach((v) => {
      this.use(v)
    })
  }
  use (...arg) {
    arg.every((v) => {
      v.init(this)
    })
  }
}

One.SYS_INFO = wx.getSystemInfoSync()
One.DEFAULT_PLUGIN = [pixiHock]
One.PIXI = PIXI
One.VER = '1.0'
One.INIT_ONE = function (config = {}) {
  let {pixelRatio, windowWidth, windowHeight} = One.SYS_INFO
  return {
    ...config,
    width: windowWidth * pixelRatio,
    height: windowHeight * pixelRatio,
    view: canvas
  }
}

export default One
export {One, PIXI}